//
//  focusTableViewCell.m
//  quickDoctor
//
//  Created by sdos on 2017/3/11.
//  Copyright © 2017年 SWS. All rights reserved.
//

#import "focusTableViewCell.h"
#import "focusDoctorMolde.h"
#import <Masonry.h>

#define RGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]

// 宏定义 随机颜色
#define RandomColor RGBColor(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))


@interface focusTableViewCell()

@property(nonatomic,weak)UILabel *doctorNameLable;
@property(nonatomic,weak)UILabel *doctorJobLable;
@property(nonatomic,weak)UILabel *doctorHospitalLable;
@property(nonatomic,weak)UILabel *cureNumberLable;
@property(nonatomic,weak)UILabel *flowerNumberLable;
@property(nonatomic,weak)UILabel *praiseNumberLable;
@property(nonatomic,weak)UILabel *percentNumberLabel;

@end


@implementation focusTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    //添加医生头像
    UIImageView *doctorImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_img_person.png"]];
    [self.contentView addSubview:doctorImageView];
    //约束
    [doctorImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.offset(10);
        make.size.mas_equalTo(CGSizeMake(80, 80));
    }];
    
    //添加医生姓名
    UILabel *doctorNameLable = [[UILabel alloc] init];
    doctorNameLable.textColor = [UIColor blackColor];
    doctorNameLable.font = [UIFont systemFontOfSize:18];
    _doctorNameLable = doctorNameLable;
    [self.contentView addSubview:doctorNameLable];
    //约束
    [doctorNameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(doctorImageView);
        make.leading.equalTo(doctorImageView.mas_trailing).offset(10);
    }];

    
    //医生职位
    UILabel *doctorJobLable = [[UILabel alloc] init];
    doctorJobLable.textColor = [UIColor lightGrayColor];
    doctorJobLable.font = [UIFont systemFontOfSize:16];
    _doctorJobLable = doctorJobLable;
    [self.contentView addSubview:doctorJobLable];
    //约束
    [doctorJobLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(doctorNameLable);
        make.leading.equalTo(doctorNameLable.mas_trailing).offset(10);
    }];
    
    
    //所属单位
    UILabel *doctorHospitalLable = [[UILabel alloc] init];
    doctorHospitalLable.textColor = [UIColor lightGrayColor];
    doctorHospitalLable.font = [UIFont systemFontOfSize:16];
    _doctorHospitalLable = doctorHospitalLable;
    [self.contentView addSubview:doctorHospitalLable];
    //约束
    [doctorHospitalLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(doctorNameLable);
        make.top.equalTo(doctorNameLable.mas_bottom).offset(10);
    }];
    
    
    //添加就诊图片
    UIImageView *cureImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yuyueliang"]];
    [self.contentView addSubview:cureImageView];
    //约束
    [cureImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(doctorHospitalLable);
        make.bottom.equalTo(doctorImageView);
    }];
    //添加就诊数量
    UILabel *cureNumberLable = [[UILabel alloc] init];
    cureNumberLable.textColor = RGBColor(47, 198, 197);
    cureNumberLable.font = [UIFont systemFontOfSize:13];
    _cureNumberLable = cureNumberLable;
    [self.contentView addSubview:cureNumberLable];
    //yues
    [cureNumberLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(cureImageView.mas_trailing).offset(8);
        make.centerY.equalTo(cureImageView);
    }];
    
    
    //添加鲜花图片
    UIImageView *flowerImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xianhua"]];
    [self.contentView addSubview:flowerImage];
    //约束
    [flowerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(cureNumberLable);
        make.leading.equalTo(cureNumberLable.mas_trailing).offset(10);
    }];
    //添加鲜花数量
    UILabel *flowerNumberLable = [[UILabel alloc] init];
    flowerNumberLable.textColor = RGBColor(47, 198, 197);
    flowerNumberLable.font = [UIFont systemFontOfSize:13];
    _flowerNumberLable = flowerNumberLable;
    [self.contentView addSubview:flowerNumberLable];
    //约束
    [flowerNumberLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(flowerImage.mas_trailing).offset(8);
        make.centerY.equalTo(flowerImage);
    }];
    
    
    //添加点赞图片
    UIImageView *praiseImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"jinqi"]];
    [self.contentView addSubview:praiseImage];
    //约束
    [praiseImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(flowerNumberLable);
        make.leading.equalTo(flowerNumberLable.mas_trailing).offset(10);
    }];
    //添加点赞数
    UILabel *praiseNumberLable = [[UILabel alloc] init];
    praiseNumberLable.textColor = RGBColor(47, 198, 197);
    praiseNumberLable.font = [UIFont systemFontOfSize:13];
    _praiseNumberLable = praiseNumberLable;
    [self.contentView addSubview:praiseNumberLable];
    //约束
    [praiseNumberLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(praiseImage);
        make.leading.equalTo(praiseImage.mas_trailing).offset(8);
    }];
    
    //添加右侧匹配度图片
    UIImageView *pipeiduImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pipeidu"]];
    [self.contentView addSubview:pipeiduImage];
    //yues
    [pipeiduImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(-5);
        make.trailing.offset(-30);
        make.size.mas_equalTo(CGSizeMake(40, 60));
    }];
    //添加匹配度label
    UILabel *pipeiduLabel = [[UILabel alloc] init];
    pipeiduLabel.text = @"匹配度";
    pipeiduLabel.textAlignment = NSTextAlignmentCenter;
    pipeiduLabel.font = [UIFont systemFontOfSize:12];
    pipeiduLabel.textColor = [UIColor whiteColor];
    [pipeiduImage addSubview:pipeiduLabel];
    //约束
    [pipeiduLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.offset(0);
        make.top.offset(10);
    }];
    //添加匹配百分比
    UILabel *percentNumberLabel = [[UILabel alloc] init];
    percentNumberLabel.textColor = [UIColor whiteColor];
    percentNumberLabel.textAlignment = NSTextAlignmentCenter;
    percentNumberLabel.font = [UIFont systemFontOfSize:12];
    _percentNumberLabel = percentNumberLabel;
    [pipeiduImage addSubview:percentNumberLabel];
    //约束
    [percentNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.offset(0);
        make.top.equalTo(pipeiduLabel.mas_bottom).offset(5);
    }];
}

- (void)setModel:(focusDoctorMolde *)model
{
    _model = model;
    
    _doctorNameLable.text = model.doctorName;
    _doctorJobLable.text = model.doctorJob;
    _doctorHospitalLable.text = model.doctorHospital;
    _cureNumberLable.text = model.cureNumber;
    _flowerNumberLable.text = model.flowerNumber;
    _praiseNumberLable.text = model.praiseNumber;
    _percentNumberLabel.text = model.percentNumber;
}

@end


